Search Results: "myon"

25 March 2013

Christoph Berg: How not to monitor a boolean

We were lazy and wrote a simple PostgreSQL monitoring check in shell instead of using some proper language. The code looked about this:
out=$(psql -tAc "SELECT some_stuff, t > now() - '1 day'::interval FROM some_table" some_db 2>&1)
case $out in
    *t) echo "OK: $out" ;;
    *) echo "NOT OK: $out" ;;
esac
If the string ends with 't', all is well, if it ends with 'f' or someting else, something is wrong. Unfortunately, this didn't go that well: OK: psql: FATAL: database "some_db" does not exist

7 February 2013

Christoph Berg: PostgreSQL minor releases

We've just put the new PostgreSQL minor releases live on apt.postgresql.org. Building 5 major versions for 10 distributions produces quite a lot of stuff: Compiling took a bit more than 10 hours on a 2-cpu VM. Of course that includes running regression tests and the postgresql-common testsuite. Note: This will be the last update published on pgapt.debian.net. Please update your sources.list entries to point to apt.postgresql.org!

7 December 2012

Christoph Berg: apt.postgresql.org

So we finally made it, and sent out an official announcement for apt.postgresql.org. This new repository hosts packages for all PostgreSQL server versions (at the moment 8.3, 8.4, 9.0, 9.1, 9.2) for several Debian/Ubuntu distributions (squeeze, wheezy, sid, precise) on two architectures (amd64, i386). Now add packages for extension modules on top of all these, and you get a really large amount of binaries from a small number of sources. Right now there's 1670 .deb files and 148 .dsc files, but the .dsc count includes variants that only differ in the version number per distribution (we attach .pgdg60+1 for squeeze packages, .pgdg70+1 for wheezy and so on), so the real number of different sources is rather something like 81, with 38 distinct source package names. Dimitri Fontaine, Magnus Hagander, and I have been working on this since I first presented the idea at PGconf.EU 2011 in Amsterdam. We now have a Jenkins server building all the packages, an archive server with the master repository, and a feed that syncs the repository to the postgresql.org FTP (well, mostly http) server. If you were previously using pgapt.debian.net, that's the same archive as on apt.postgresql.org (one rsync away). Please update your sources.list to point to apt.postgresql.org, I'll shut down the archive at that location at the end of January. Here's the Quickstart instructions from the Wiki page: Import the repository key from http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc:
wget -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc   sudo apt-key add -
Edit /etc/apt/sources.list.d/pgdg.list. The distributions are called codename-pgdg. In the example, replace squeeze with the actual distribution you are using:
deb http://apt.postgresql.org/pub/repos/apt/ squeeze-pgdg main
Configure apt's package pinning to prefer the PGDG packages over the Debian ones in /etc/apt/preferences.d/pgdg.pref:
Package: *
Pin: release o=apt.postgresql.org
Pin-Priority: 500
Note: this will replace all your Debian/Ubuntu packages with available packages from the PGDG repository. If you do not want this, skip this step. Update the package lists, and install the pgdg-keyring package to automatically get repository key updates:
apt-get update
apt-get install pgdg-keyring

30 November 2012

Christoph Berg: pgbouncer running on the same hardware

We have a PostgreSQL server with 16 cores that was apparently running well below its capacity: load something between 3.0 and 4.0, around 200 active database connections, almost all always being <IDLE>. However, when the tps count reached 7k transactions per second, things started to throttle, and pgbouncer (running on the database server) started listing up to half of the client connections to be in cl_waiting state. Load was still low, but application performance was bad. The culprit turned out to be the kernel scheduler, fairly distributing CPU time among all running processes. There's one single pgbouncer process, but hundreds of postgres processes. A simple renice of the pgbouncer process did the trick and gave us another extra 2k tps.

26 November 2012

Christoph Berg: Shared Memory and Swapping

We have this PostgreSQL server with plenty of RAM that is still using some of its swap over the day (up to 600MB). Then suddenly everything is swapped in again. It turned out the reason is there are two clusters running, and the second one isn't used as heavily as the first one. Disk I/O activity of the first cluster slowly evicts pages from the second shared buffers cache to swap, and then the daily pg_dump run reads them back every evening. I was not aware of an easy way to get numbers for "amount of SysV shared memory swapped to disk", but some googling led to shmctl(2):
#define _GNU_SOURCE 1
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>
#include <unistd.h>
int main ()
 
        struct shm_info info;
        int max;
        long PAGE_SIZE = sysconf(_SC_PAGESIZE);
        max = shmctl(0, SHM_INFO, (struct shmid_ds *) &info);
        printf ("max: %d\nshm_tot: %ld\nshm_rss: %ld\nshm_swp: %ld\n",
                        max,
                        info.shm_tot * PAGE_SIZE,
                        info.shm_rss * PAGE_SIZE,
                        info.shm_swp * PAGE_SIZE);
        return 0;
 
The output looks like this:
max: 13
shm_tot: 13232308224
shm_rss: 12626661376
shm_swp: 601616384
Update: Mark points out that ipcs -mu shows the same information. Thanks for the hint!
# ipcs -mu
------ Shared Memory Status --------
segments allocated 2
pages allocated 3230544
pages resident  3177975
pages swapped   51585
Swap performance: 0 attempts     0 successes

22 November 2012

Christoph Berg: grep -r foobar

In Wheezy's grep version [1], you can omit the "." in
$ grep -r foobar .
and just write
$ grep -r foobar
[1] actually since 2.11

1 October 2012

Christoph Berg: mkfs.ext3 -b 1024

If you think you are smart and create an ext filesystem with 1024 bytes blocksize because there will be zillions of very small files, and then run into ENOSPC errors while there's both space and inodes left, you will probably see ext3_dx_add_entry: Directory index full! in the kernel log. Turns out that there's a limit of approximately 300,000 files per directory with 1k blocks, after which some hash tables are full. Recreate the filesystem with 2k blocks and the limit will be MUCH higher.

27 August 2012

Christoph Berg: PostgreSQL in Debian Hackathon

Almost a year has passed since my talk at pgconf.eu 2011 in Amsterdam on Connecting the Debian and PostgreSQL worlds, and unfortunately little has happened on that front, mostly due to my limited spare time between family and job. pgapt.debian.net is up and running, but got few updates and is lagging behind on PostgreSQL releases. Luckily, we got the project moving. Dimitri Fontaine and Magnus Hagander suggested to do a face-to-face meeting, so we got together at my house for two days last week and discussed ideas, repository layouts, build scripts, and whatnot to get all of us aligned for pushing the project ahead. My employer sponsored my time off work for that. We almost finished moving the repository to postgresql.org infrastructure, barring some questions of how to hook the repository into the existing mirror infrastructure; this should get resolved this week. The build server running Jenkins is still located on my laptop, but moving this to a proper host will also happen really soon now. We are using Mika Prokop's jenkins-debian-glue scripts for driving the package build from Jenkins. The big plus point about Jenkins is that it makes executing jobs on different distributions and architectures in parallel much easier than a bunch of homemade shell scripts could get us with reasonable effort. Here's a list of random points we discussed: We really aim at using unmodified packages from Debian as much as possible, and in fact this project doesn't mean to replace Debian's PostgreSQL packaging work, but to extend it beyond the number of server versions (and Debian and Ubuntu versions covered) supported. The people behind the Debian and Ubuntu packages, and this repository are mostly the same, so we will claim that "our" packages will be the same quality as the "original" ones. Big thanks go to Martin Pitt for maintaining the postgresql-common testsuite that really covers every aspect of running PostgreSQL servers on Debian/Ubuntu systems. Stay tuned for updates! :)

19 July 2012

Christoph Berg: Machine Check Exception

Today's wtf:
Wed Jul 18 20:25:01 CEST 2012 MCA: Generic CACHE Generic Generic Error

7 May 2012

Christoph Berg: Andreas

May 7th, 2012

20 March 2012

Christoph Berg: Cool Unix Features: /usr/bin/time

Ever wondered how much memory a program needed? Install the "time" package:
$ /usr/bin/time ls
[...]
0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 4000maxresident)k
0inputs+0outputs (0major+311minor)pagefaults 0swaps
Unfortunately the "time" bash built-in makes it necessary to use the full path. Thanks to youam for the tip. Update: aba notes that calling \time works as well. Thanks!

30 January 2012

Christoph Berg: How not to edit files

When packaging new backport versions, I diff the old Debian package with the old backport package to extract the changes I did there, and then apply this patch to the new version. There is always a reject in debian/changelog because the topmost bpo entry won't apply cleanly to the new changelog. To fix this, I invoke "vi debian/changelog*" and manually copy the rejected hunk. Unfortunately, I regularly end up copying it from debian/changelog.rej (buffer 3) into debian/changelog.orig (buffer 2) instead of debian/changelog (buffer 1). Here's the fix in my .vimrc:
" Prevent accidental editing of patch .orig files
autocmd BufRead *.orig set readonly

27 December 2011

Christoph Berg: Generating symbols files from a series of .deb files

PostgreSQL's libpq5 package got its symbols file somewhere around version 8.4, so the symbols in there were all marked with version "8.4~" or greater. As I'm working on pgapt.debian.net aiming at providing packages for all upstream-supported PG versions (currently 8.3 and up), this made packages incompatible with 8.3's libpq5. There didn't seem to be a ready program to feed a series of .deb files which would then run dpkg-gensymbols and build a symbols file, so I wrote this shell script:
#!/bin/sh
set -eu
[ -d tmp ]   mkdir tmp
i=1
for pkg in "$@" ; do
    echo "$pkg"
    test -e "$pkg"
    name=$(dpkg-deb -I "$pkg"   perl -lne 'print $1 if /^ Package: (.+)/')
    version=$(dpkg-deb -I "$pkg"   perl -lne 'print $1 if /^ Version: (.+)/')
    out=$(printf "tmp/%03d_%s" $i "$version")
    dpkg-deb -x "$pkg" "$out"
    dpkg-gensymbols -P"$out" -p"$name" -v"$version" \
        $ oldsymbols:+-I"$oldsymbols"  -O"$out.symbols"   \
        tee "$out.symbols.diff"
    test -s "$out.symbols.diff"   rm "$out.symbols.diff"
    oldsymbols="$out.symbols"
    rm -rf "$out"
    i=$(expr $i + 1)
done
To use it, do the following: The highest-numbered *.symbols file in tmp/ will then have symbol information for all packages. I then did some manual post-processing like s/~rc1-1/~/ to get nice (and backportable) version numbers. Another nice trick (pointed out by jcristau) is to replace the lowest version number of that package (8.2~ here, where libpq changed SONAME) by 0 which will make dpkg-shlibdeps omit the >= version part. (Most packages depending on libpq5 will profit from that.) I'm still pondering whether this script is non-trivial enough add to devscripts. (The people I asked so far only made comments about the mkdir call...)

26 September 2011

Jan Hauke Rahm: zsh, tab completion, remote hosts, and collaboration

Using zsh as default shell is perfect. Using grml-zsh stuff to configure it, even better. Using XTaran s config, way better. Using your own config, invaluable. Now, there is one thing that always bothered me: having all hosts I usually deal with in my ~/.ssh/config in order to have tab completion (and short names). I wanted to improve the situation and was kindly pointed in a different direction by Myon, namely to just use the ~/.ssh/known_hosts for tab completion. How about that? I started playing around with the config and, as it turns out, Axel already has something ready. Unfortunately, it didn t fulfill all my needs yet. That is because I have multiple known_hosts files. Martin already filed a bug to have ssh read ~/.ssh/known_hosts.d/* but that isn t resolved yet either, even though upstream is aware of it. I thus had to point tab completion and ssh to multiple files by hand. But that s not too bad for now. Let s have a look: Host *
HashKnownHosts no
Host *.your-work.com
User that-is-what-they-call-me-at-work
UserKnownHostsFile ~/.ssh/known_hosts.work
Host *.debian.org
UserKnownHostsFile ~/.ssh/known_hosts.debian
What am I doing? Well, we need to deactivate the hashing of known hosts. Otherwise your known_hosts files aren t readable as needed. Then you define your known_hosts files for the domains you care about. Pretty straight forward. Now, how about tab completion in zsh? Well, easy part actually: [ -f ~/.ssh/config ] && : $ (A)ssh_config_hosts:=$ $ $ $ (@M)$ (f)"$(<~/.ssh/config)" :#Host * #Host :#*\** :#*\?*
[ -f ~/.ssh/known_hosts ] && : $ (A)ssh_known_hosts:=$ $ $ (f)"$(<$HOME/.ssh/known_hosts)" %%\ * %%,*
[ -f ~/.ssh/known_hosts.work ] && : $ (A)ssh_known_hosts_work:=$ $ $ (f)"$(<$HOME/.ssh/known_hosts.work)" %%\ * %%,*
[ -f ~/.ssh/known_hosts.debian ] && : $ (A)ssh_known_hosts_debian:=$ $ $ (f)"$(<$HOME/.ssh/known_hosts.debian)" %%\ * %%,*
zstyle ':completion:*:hosts' hosts $ssh_config_hosts $ssh_known_hosts $ssh_known_hosts_work $ssh_known_hosts_debian What's here? We read and parse your ~/.ssh/config for configured hosts, then we parse all your known_hosts files which are for me: ~/.ssh/known_hosts, ~/.ssh/known_hosts.work, and ~/.ssh/known_hosts.debian. And lastly, all is added to zsh completion for hosts. That actually works. :) Axel, that makes a diff for you looking like this: diff --git a/zsh.d/70-completion b/zsh.d/70-completion
index e92e068..5abf5cc 100644
--- a/zsh.d/70-completion
+++ b/zsh.d/70-completion
@@ -8,6 +8,8 @@
[ -f ~/.ssh/config ] && : $ (A)ssh_config_hosts:=$ $ $ $ (@M)$ (f)"$(<~/.ssh/config)" :#Host * #Host :#*\** :#*\?*
[ -f ~/.ssh/known_hosts ] && : $ (A)ssh_known_hosts:=$ $ $ (f)"$(<$HOME/.ssh/known_hosts)" %%\ * %%,*
+[ -f ~/.ssh/known_hosts.work ] && : $ (A)ssh_known_hosts_work:=$ $ $ (f)"$(<$HOME/.ssh/known_hosts.work)" %%\ * %%,*
+[ -f ~/.ssh/known_hosts.debian ] && : $ (A)ssh_known_hosts_debian:=$ $ $ (f)"$(<$HOME/.ssh/known_hosts.debian)" %%\ * %%,*
-zstyle ':completion:*:*:*' hosts $ssh_config_hosts $ssh_known_hosts
+zstyle ':completion:*:hosts' hosts $ssh_config_hosts $ssh_known_hosts $ssh_known_hosts_work $ssh_known_hosts_debian
Care to merge? Oh, and before I forget... Of course you don't need to check each and every host by yourself. Debian provides ssh keys for all hosts on master. Just do a scp master.debian.org:/etc/ssh/ssh_known_hosts ~/.ssh/known_hosts.debian and I'm sure, your security aware employer has such a file for you as well. Doesn't he? ;)

19 September 2011

Christoph Berg: Tab completion in vim

Vim's habit of completing the full filename of the first match on :e has always annoyed me. Rhonda pointed me to wildmode - thanks!
set wildmode=longest,list:longest,list:full

26 August 2011

Axel Beckert: Useful but Unknown Unix Tools: Kill all processes of a user

I already got mails like What a pity that your nice blog posting series ended . No, it didn t end. As announced, I knew that I won t be able to keep up a daily schedule. It worked as long as I had already written the postings in advanced. But in the end the last postings were already written just in time and then I ran out of leisure and muse for a time. But as I said: It didn t end, it will be continued. And this is the next such posting. Oh, and for those who tell me further tools, I should blog about: I appreciate that, especially because that way I also hear about tools I didn t know about. But why just telling me and not blogging yourself about it? :-) At least those whose blog is part of Planet Debian or Planet Symlink anyway really should do this themselves. I d really like to see also others writing about cool tools. I neither have a right on the idea nor on the name of this series (call it meme if you want :-), so please go on and publish your favourite tools in a blog posting, too. :-) And for all those who want to join me and Myon blogging about cool Unix tools, independent if listed on Planet Debian or Planet Symlink, I encourage you to offer a separate feed for this kind of postings and join us on Planet Commandline. Anyway, here s the next such posting: As system administrator you often have the case that you have to kill all processes of one user, e.g. if a daemon didn t properly shut down itself or amok running leftovers of a GUI session. Many use pkill -SIGNAL -u user from the procps package or killall -SIGNAL -u user from the psmisc package for it. But that s a) quite cumbersome to type and b) is there a chance to forget about the -u and then bad things may happen, especially with pkill s default substring match, so I prefer another tool with a more explicit name:

slay slay has an easy to remember name (at least for BOFHs ;-) which is even quicker to type (alternating one character with the left and the right hand, at least on US layout keyboards) than pkill (all characters to type with the right hand), and has the same easy to remember commandline syntax like kill itself:
slay -SIGNAL user [user  ]
But beware, slay is

not only for BOFHs, but also from a BOFH It has a mean mode which is activated by default. With mean mode on, it won t kill the given user but the user who called the program if it is invoked as an ordinary user without root rights. *g* Interestingly I never ran into this issue despite I use this program often and for many years now. But some Ubuntu users did, probably because adding a sudo in front of some command is easier to forget than doing an ssh root@localhost or su - beforehand. They even seem to be so desperate about it that they forwarded the issue from Launchpad to the Debian Bug Tracking System. ;-) But to be honest even if I was very amused about those bug reports isn t this issue grave , as it causes very likely (unexpected) data loss?

Now playing: Monzy kill dash nine ( and your process is mine ;-)

12 July 2011

Christoph Berg: Kudos to dh_python2

Transitioning Python modules to dh_python2 is straightforward. I removed LOADS of magic from python-radix. I especially like the complexity reduction in debian/rules, but debian/control also got some fields removed.

26 May 2011

Christoph Berg: DLV removes all *.de records

Because of some problem with Denic's DNSSEC testbed and bind resolvers, dlv.isc.org has removed all DLV records for *.de domains. WTF.

3 May 2011

Christoph Berg: Marriage and Baptism

29. April 2011

31 March 2011

Christoph Berg: PostgreSQL in Debian

At work, I'm dealing with lots of different database setups, luckily mostly PostgreSQL running on Debian. At the same time, a fair amount of the tools in the PostgreSQL ecosystem (not the PostgreSQL server packages itself) are not in the best shape in the Debian archive. I'm trying to change that by adopting some of the packages. So far, I have fixed a few RC bugs where packages where suddenly trying to build against PostgreSQL 9.0 while expecting 8.4. To my surprise, there are no packages yet in the archive that support multiple PostgreSQL versions in parallel. There is even a package ready to help doing this - postgresql-server-dev-all, but apparently nobody has used it yet. It turned out that after working around a few trivial problems and adding just a few lines of sh code, it was pretty straightforward to port skytools and postgresql-pllua to 9.0 while keeping 8.4 support. The latter has no version-specific code left in debian/ except for a list of supported versions in debian/pgversions, so a future port to 9.1 will be trivial. (Fun fact: the old postgresql-pllua version 0.8.1 was actually a typoed 0.3.1 version.) Most PostgreSQL tools use a common subversion repository on Alioth, but there is no common mailing list address that is put into the Uploaders fields, so it is hard to get an overview over the state of all packages. I've compiled a list of all packages in svn, git, bzr (the server packages), and a few others in DDPO to fix that for now. Other packages I've updated so far are pgtune, pgbouncer, and pgpool2.

Next.

Previous.